import router from "./router";
import { cci_login_init } from "@/api/usertype";
let userinfo = {}
let fopenid = "ceshi";
router.beforeEach((to, from, next) => {
    cci_login_init({
        url: "",
        fopenid: fopenid
    }).then(res => {
        if (res.isSuccess) {
            userinfo = res.map.userInfo[0];
            if (fopenid) {
                if (to.path == "/") {
                    if (userinfo.fusertype == 9024) {
                        console.log("-----");
                        next();
                    } else if (userinfo.fusertype == 9020) {
                        console.log("1111");
                        next({
                            path: "/govIndex"
                        });
                    }
                }else{
                    next();
                }
                if (to.path == "/govIndex") {
                    if (
                        userinfo.fusertype == 9024 ||
                        userinfo.fusertype == 9020
                    ) {
                        next();
                    } else if (userinfo.fusertype == 9021) {
                        // 此处停跳转至对应页面
                        next({
                            path: "/govsearchResult"
                        });
                    }
                }else{
                    next();
                }
            }else{
                next();
            }
        }
    });
});

